package com.pearadmin.pro.modules.experiment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pearadmin.pro.common.web.base.page.PageRequest;
import com.pearadmin.pro.common.web.base.page.PageResponse;
import com.pearadmin.pro.common.web.base.page.Pageable;
import com.pearadmin.pro.modules.experiment.entity.ExperimentAccessory;
import com.pearadmin.pro.modules.experiment.entity.ExperimentBulletin;
import com.pearadmin.pro.modules.experiment.entity.ExperimentInfo;
import com.pearadmin.pro.modules.experiment.mapper.ExperimentAccessoryDao;
import com.pearadmin.pro.modules.experiment.mapper.ExperimentBulletinDao;
import com.pearadmin.pro.modules.experiment.mapper.ExperimentInfoDao;
import com.pearadmin.pro.modules.experiment.mapper.ExperimentMajorDao;
import com.pearadmin.pro.modules.experiment.service.ExperimentBulletinService;
import com.pearadmin.pro.modules.experiment.service.ExperimentService;
import com.pearadmin.pro.modules.sys.domain.SysConfig;
import com.pearadmin.pro.modules.sys.param.SysConfigRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ExperimentBulletinServiceImpl extends ServiceImpl<ExperimentBulletinDao, ExperimentBulletin> implements ExperimentBulletinService {

    @Resource
    private ExperimentBulletinDao experimentBulletinDao;

    @Resource
    private ExperimentAccessoryDao experimentAccessoryDao;


    @Override
    public PageResponse<ExperimentBulletin> getAnnouncementList(PageRequest request) {
        return Pageable.of(request,(()-> experimentBulletinDao.getAnnouncementList(request)));
    }
    @Override
    public PageResponse<ExperimentBulletin> getNewsList(PageRequest request) {
        return Pageable.of(request,(()-> experimentBulletinDao.getNewsList(request)));
    }

    @Override
    public boolean insertSelective(ExperimentBulletin experimentBulletin) {
        int i = experimentBulletinDao.insertSelective(experimentBulletin);
        return i>0;
    }


    @Override
    public ExperimentBulletin viewDetails(String id) {
        ExperimentBulletin experimentBulletin = experimentBulletinDao.selectByPrimaryKey(Integer.valueOf(id));
        List<ExperimentAccessory> experimentAccessoryList = experimentAccessoryDao.selectListByEbId(id);
        experimentBulletin.setExperimentAccessoryList(experimentAccessoryList);
        return experimentBulletin;
    }
}
